<template>
  <el-container class="home-container">
    <!-- 头部区域 -->
    <el-header>
      <div class="fontCorlor">
        <i class="el-icon-eleme" />
        <span>后台管理系统</span>
      </div>
      <div>
        <el-dropdown @command="handleCommand">
          <span class="el-dropdown-link">
            <img src="../assets/head-sip.png" alt="" />个人中心
          </span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item command="1">消息中心</el-dropdown-item>
            <el-dropdown-item command="2">退出登录</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </el-header>

    <!-- 页面主题 -->
    <el-container>
      <!-- 导航栏左边 -->

      <div class="sytab">
        <div class="sinp" :class="cur=='/welcome'?'select':'normal'" @click="handel('index')" >
          <i class="el-icon-s-home"></i><span>系统首页</span>
        </div>
        <div class="sinp"  :class="cur=='/users'?'select':'normal'" @click="handel('user')" >
          <i class="el-icon-s-custom"></i><span>用户管理</span>
        </div>
        <div class="sinp" :class="cur=='/tasklist'?'select':'normal'" @click="handel('set')">
          <i class="el-icon-menu" ></i><span>任务集合</span>
        </div>
        <div class="sinp" :class="cur=='/roles'?'select':'normal'" @click="handel('task')">
          <i class="el-icon-s-tools"></i><span>系统设置</span>
        </div>
      </div>
      <!-- 右侧neir -->
      <el-main>
        <!-- 路由占位符 -->
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>
<script>
export default {
  data() {
    return {
      cur: '/welcome',
      menulist: [],
      iconsObj: {
        125: "el-icon-s-custom",
        103: "el-icon-set-up",
        101: "el-icon-s-goods",
        102: "el-icon-tickets",
        145: "el-icon-pie-chart",
      },
      isCollapse: false,
      //被激活链接的地址
      // activepath: "",
    };
  },
  created() {
    this.getMenuList();
    this.cur=this.$route.path
    //   (this.activepath = window.localStorage.getItem("activepath"));
    // this.activepath = activepath;
  },
  methods: {
    // dropdown(val) {
    //   window.localStorage.clear();//清空token
    //   if(val !== '1'){
    //     this.$router.push('/Login')
    //     console.log('111111')
    //   }
    // },
    handel(val) {
      switch (val) {
        case "index":
          this.cur = '/welcome';
          this.$router.push("/welcome");
          break;
        case "user":
          this.cur = '/users';
          this.$router.push("/users");
          break;
        case "set":
          this.cur = '/tasklist';
           this.$router.push("/tasklist")
          break;
        case "task":
          this.cur = '/roles';
          this.$router.push("/roles");
      }
    },
    handleCommand(command) {
      if (command == "2") {
        this.$router.push("/login");
      }
    },
    //获取所有菜单
    async getMenuList() {
      const { data: res } = await this.$http.get("/admin/main",{});
      // const { data: res } = await this.$http.get("invoke",{command:'restDailyPurchase',version:20160607});
      if (res.code == 200) return this.$message.success(res.msg);
      this.menulist = res.data;
      console.log(res);
    },
    //点击按钮，切换菜单的折叠与展开
    toggleCollapse() {
      this.isCollapse = !this.isCollapse;
    },
    //保存连接的激活状态
    // savaNavState(activepath) {
    //   window.localStorage.setItem("activepath", activepath);
    // },
  },
};
</script>
<style scoped lang="less">
.select{color:#1989fa !important}
.el-dropdown-link {
  display: block;
  align-items: center;
  font-size: 14px;
  cursor: pointer;
}
// .fontCorlor {
//   color: #4f6bff !important;
// }
.sytab {
  justify-content: center;
}
.sytab i {
  font-size: 28px;
}
.sinp {
  width: 80px;
  height: 65px;
  text-align: center;
  padding: 12px;
  font-size: 12px;
  color: #9ca2a9;
}
.sinp:hover {
  cursor: pointer;
  color: #4f6bff;
}
.sytab span {
  display: block;
  margin-top: 5px;
}

.el-container {
  height: 100%;
}

.el-header {
  box-shadow: 0 2px 16px rgba(31, 35, 41, 0.05);
  display: flex;
  justify-content: space-between;
  padding-left: 30px;
  align-items: center;
  color: #0e3a6d;
  font-size: 20px;
  > div {
    display: flex;
    align-items: center;
    img {
      height: 30px;
    }
    span {
      margin-left: 5px;
    }
  }
}

.el-aside {
  .el-menu {
    border-right: none;
  }
}
.toggle-button {
  font-size: 10px;
  line-height: 24px;
  color: #fff;
  text-align: center;
  letter-spacing: 0.2em;
  cursor: pointer;
}
</style>